<?php
/**
*/
namespace builder\console\commands;

use ulue\cli\SimpleApplication;

class TestCommand extends SimpleApplication
{

    protected function beginExecute()
    {
        $this->io->out('welcome');

         // Get options
        $help = $this->io->getOption('h');

        if ($help)
        {
            $msg = <<<MSG
Help message: version 1.0
------------------------------------
myapp.php <command> [-options]

  foo    Description of this command.
  bar    Description of this command.
  help   Description of this command.
MSG;

            $this->io->out($msg);

            $this->close();
        }
        //linux
        // $this->passthru('ls -al '.  str_replace('\\', '/',realpath('./../../../')) . ' | grep *.json');
        // $this->passthru('grep 127.0.0.1 '.$this->formatPath('C:\Windows\System32\drivers\etc\hosts') );

        //win
        $this->passthru('dir /A '.dirname('C:\Windows\System32\drivers\etc\hosts') );
        // $this->passthru('FIND "blogdf.com" C:\Windows\System32\drivers\etc\hosts' );


        // $this->exec('cat '. str_replace('\\', '/', __FILE__ ));
    }

    public function catFile($name)
    {
        # code...
    }

    protected function formatPath($path)
    {
        return str_replace('\\', '/', trim($path) ) ;
    }
}

